require "purchase/pchCfg"

pchCenter = pchCenter or {}


function pchCenter:setAndroidChannelAndInit( ch )
	-- body
    local targetPlatform = cc.Application:getInstance():getTargetPlatform()
    if cc.PLATFORM_OS_ANDROID == g_targetPlatform then
    
        self.ch = ch
        self.handler = nil

        self.handler = require (ch.file)

        --init
        -- self.handler:init_callJava()

    end 	

end



function pchCenter:order(item)
	self.curItem = item

	local bOrderOk = false
	if self.handler and DEF_PURCHASE then
		--self.handler:order_callJava(self.curItem)	--use for cte,mm,uni
		bOrderOk = self.handler:order_callJava(appInfo.channelId, userData.id, item)
	else
		d_print("channel unset!")
	end

	return bOrderOk
end

function pchCenter_billingResult_fromJava(retStr)
    
	if retStr == "success" then
        d_print("billingCallback !!!!!!!!!!!!success")
		pchCenter.curItem.processOk()

	else
		d_print("billingCallback !!!!!!!!!!!!fail")
		pchCenter.curItem.processFail()
	end
end
